#include "SymptomGroup.h"


SymptomGroup::SymptomGroup(SymptomBuilder* parent,const QString& name)
{
	this->builder = parent;
	this->name = name;
	_createButtonArea();
	_createGroupBoxArea();
}


void SymptomGroup::_createButtonArea()
{
	QVBoxLayout * layout = static_cast<QVBoxLayout*>(builder->getParent());
	if(!layout)
		return;

	this->button = new QCommandLinkButton(name);
	button->setObjectName(QString("%1CommandLinkButton").arg(name));
	layout->addWidget(button);
}

void SymptomGroup::_createGroupBoxArea()
{
	QVBoxLayout * layout = static_cast<QVBoxLayout*>(builder->getParent());
	if(!layout)
		return;

	this->box = new QGroupBox(this->name);
	this->box->setObjectName(QString("%1GroupBox").arg(name));
	//this->box->setMinimumSize(500,300);

	layout->setStretch(layout->count()-1,1);
	layout->addWidget(box);

	this->grid = new QGridLayout(box);
	this->grid->setObjectName(QString("%1GridLayout").arg(name));
}

void SymptomGroup::buildGroup(const QStringList& unitNames)
{
	QString unitName;
	foreach(unitName,unitNames)
		this->addSymptomUnit(unitName);
}

SymptomUnit* SymptomGroup::addSymptomUnit(const QString& unitName)
{
	if(this->nameSymptomUnitMap.value(unitName))
		return 0;
	SymptomUnit* unit = new SymptomUnit(this,unitName,this->nameSymptomUnitMap.count());
	this->nameSymptomUnitMap.insert(unitName,unit);
	return unit;
}

SymptomGroup::~SymptomGroup(void)
{
}
